package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.model.MessageClassify;
import com.ytjj.qmyx.admin.service.MessageClassifyService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 *
 * 消息分类
 */
@RestController
@AllArgsConstructor
@RequestMapping("/messageClassify")
public class MessageClassifyController {

    private MessageClassifyService messageClassifyService;

    /**
     * 消息分类列表
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public CommonResult selectMessageClassifyPage(Integer pageNum, Integer pageSize) {
        return CommonResult.success(messageClassifyService.selectMessageClassifyPage(pageNum,pageSize));
    }

    /**
     * 消息分类详情
     * @param id
     * @return
     */
    @GetMapping("/selectMessageClassify")
    public CommonResult selectMessageClassify(Integer id) {
        return CommonResult.success(messageClassifyService.selectMessageClassify(id));
    }

    /**
     * 新增分类
     * @param messageClassify
     * @return
     */
    @PostMapping("/insertMessageClassify")
    public CommonResult insertMessageClassify(@RequestBody MessageClassify messageClassify) {
        return CommonResult.success(messageClassifyService.insertMessageClassify(messageClassify));
    }

    /**
     * 修改分类
     * @param messageClassify
     * @return
     */
    @PostMapping("/updateMessageClassify")
    public CommonResult updateMessageClassify(@RequestBody MessageClassify messageClassify) {
        return CommonResult.success(messageClassifyService.updateMessageClassify(messageClassify));
    }

    /**
     * 消息分类下拉框
     * @return
     */
    @GetMapping("/selectClassifyName")
    public CommonResult selectClassifyName() {
        return CommonResult.success(messageClassifyService.selectClassifyName());
    }

}
